﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Hotnet.Entity;
using Hotnet.Dal.BaseRepository;
using Hotnet.Entity.Search;

namespace Hotnet.Dal.NSDalMusic
{
	public class DalMusicGroup : Repository<MusicGroup>
	{
		public MusicGroup[] List(int categoryId, int pageNo, int pageSize, out int totalSize, SearchMusicCondition smc)
		{

			var query = (from musicGroup in disableCacheDataContext.MusicGroup
						 where musicGroup.CategoryID == categoryId && musicGroup.Name.Contains(smc.Name ?? "") && musicGroup.Stars.Contains(smc.StarName ?? "")
						 select musicGroup).Skip(pageNo * pageSize).Take(pageSize);

			totalSize = (from musicGroup in disableCacheDataContext.MusicGroup
						 where musicGroup.CategoryID == categoryId && musicGroup.Name.Contains(smc.Name ?? "") && musicGroup.Stars.Contains(smc.StarName ?? "")
						 select musicGroup).Count();

			return query.ToArray();
		}
	}
}
